package com.jxtc.enterprise.common.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.jxtc.enterprise.common.entity.DeliveryTask;
import com.jxtc.enterprise.delivery.dto.historyData.DailyTaskIncomeDTO;
import com.jxtc.enterprise.delivery.dto.historyData.DeliveryTaskWithCompanyDTO;
import com.jxtc.enterprise.delivery.dto.todayTask.CompanyIdWithMealTypeDTO;
import com.jxtc.enterprise.delivery.dto.todayTask.RiderTodayTaskDTO;
import com.jxtc.enterprise.tenant.dto.deliveryCommission.DeliveryOrderCalculateDTO;
import com.jxtc.enterprise.tenant.vo.delliveryCommissionManage.DeliveryCommissionVO;
import com.jxtc.enterprise.tenant.vo.delliveryCommissionManage.DeliveryMiscellaneousFeeVO;
import com.jxtc.enterprise.tenant.vo.delliveryCommissionManage.DeliveryTaskBriefInfoVO;
import org.apache.ibatis.annotations.Param;

import java.util.List;

public interface DeliveryTaskMapper extends BaseMapper<DeliveryTask> {
    /**
     * 分页查询配送员今日配送任务
     *
     * @param page         分页参数
     * @param riderId      配送员 ID
     * @param status       配送状态
     * @param deliveryDate 配送日期
     * @return 配送员今日配送任务列表
     */
    Page<RiderTodayTaskDTO> pageTodayTask(Page<RiderTodayTaskDTO> page,
                                          @Param("riderId") String riderId,
                                          @Param("deliveryStatus") int status,
                                          @Param("deliveryDate") String deliveryDate);


    /**
     * 通过配送任务 ID 获取对应的公司 ID及用餐时段
     *
     * @param taskId 配送任务 ID
     * @return 公司 ID 和用餐时段信息
     */
    CompanyIdWithMealTypeDTO queryCompanyIdByTaskId(@Param("taskId") String taskId);

    Page<DeliveryCommissionVO> queryDeliveryTaskByRiderNamePhoneOrCompanyName(Page<DeliveryCommissionVO> page,
                                                                              @Param("tenantId") String tenantId,
                                                                              @Param("keyword") String keyword,
                                                                              @Param("startDate") String startDate, @Param("endDate") String endDate,
                                                                              @Param("startTime") String startTime, @Param("endTime") String endTime,
                                                                              @Param("deliveryStatus") int deliveryStatus,
                                                                              @Param("settlementStatus") int settlementStatus);


    List<DeliveryTaskBriefInfoVO> queryDeliveryDetailByTaskId(@Param("taskId") String taskId);


    DeliveryMiscellaneousFeeVO queryDeliveryMisscellaneousFee(@Param("taskId") String taskId);

    String queryDeliveryTaskProofImages(@Param("taskId") String taskId);

    Integer queryTotalIncome(@Param("riderId") String riderId);

    Integer queryMonthlyIncome(@Param("riderId") String riderId,
                               @Param("firstDayOfMonth") String firstDayOfMonth,
                               @Param("lastDayOfMonth") String lastDayOfMonth);

    /**
     * 分页查询配送员每日任务与收入
     *
     * @param page    分页参数
     * @param riderId 配送员 ID
     * @return 每日任务与收入列表
     */
    Page<DailyTaskIncomeDTO> pageDailyTaskAndIncome(Page<DailyTaskIncomeDTO> page, @Param("riderId") String riderId);

    List<DeliveryTaskWithCompanyDTO> queryDeliveryTaskWithCompanyByRiderIdAndDate(@Param("riderId") String riderId, @Param("deliveryDate") String deliveryDate);
    List<DeliveryCommissionVO> queryDeliveryTaskByRiderNamePhoneOrCompanyNameForExport(Page<DeliveryCommissionVO> page,
                                                                              @Param("tenantId") String tenantId,
                                                                              @Param("keyword") String keyword,
                                                                              @Param("startDate") String startDate, @Param("endDate") String endDate,
                                                                              @Param("startTime") String startTime, @Param("endTime") String endTime,
                                                                              @Param("deliveryStatus") int deliveryStatus,
                                                                              @Param("settlementStatus") int settlementStatus);

    List<DeliveryOrderCalculateDTO> calculateDeliveryOrderCommissionByTaskIdList(@Param("taskIdList") List<String> taskIdList);
}
